import './assets/main.css'
import { createApp } from 'vue'
import App from './App.vue'
import router from './router'
import ElementPlus from 'element-plus'
import 'element-plus/dist/index.css'
import * as ElementPlusIconsVue from '@element-plus/icons-vue'

const app = createApp(App)

// 使用Vue Router
app.use(router)

// 使用Element Plus
app.use(ElementPlus)

// 注册所有图标
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
  app.component(key, component)
}

// 注入自定义全局样式以修复输入框问题
const fixInputNumberStyle = document.createElement('style')
fixInputNumberStyle.textContent = `
  .el-input-number .el-input__inner {
    color: #606266 !important;
    visibility: visible !important;
    opacity: 1 !important;
    text-align: center !important;
  }
  .el-input-number.is-controls-right .el-input__inner {
    padding-left: 15px !important;
    padding-right: 50px !important;
  }
`
document.head.appendChild(fixInputNumberStyle)

// 全局错误处理
app.config.errorHandler = (err, vm, info) => {
  console.error('全局错误:', err)
  // ElMessage.error('系统出现错误，请刷新页面重试')
}

app.mount('#app')
